package com.course.service.impl;

import com.course.entity.ResultBody;
import com.course.mapper.CourseDisplayMapper;
import com.course.service.CourseDisplayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class CourseDisplayServiceImpl implements CourseDisplayService {
    @Autowired
    private CourseDisplayMapper courseManMapper;
    @Override
    public  ResultBody courseList()
    {
        if (courseManMapper.courseList().isEmpty())
        {
            return new ResultBody(400,"暂无课程",false);
        }
        return new ResultBody(200,"展示课程列表成功",courseManMapper.courseList(),courseManMapper.courseList().size());
    }

    @Override
    public ResultBody courseMessage(Map<String,Object>map)
    {
        if(courseManMapper.courseMessage(map).isEmpty())
        {
            return new ResultBody(400,"展示课程详细信息失败",false);
        }
        else
            return new ResultBody(200,"展示课程详细信成功",courseManMapper.courseMessage(map));
    }

    @Override
    public ResultBody teachmessage(Integer usernumber)
    {
        if(courseManMapper.teachmessage(usernumber).isEmpty())
            return new ResultBody(400,"展示课程信息失败",false);
        else
            return new ResultBody(200,"展示课程信息成功呢",courseManMapper.teachmessage(usernumber),courseManMapper.teachmessage(usernumber).size());
    }

}
